<?php
namespace app\app\model;
use think\Model;
class Talkhf extends Model
{
    public function creatTalkhf($hf_data)
    {
        $talkhf = new Talkhf;
        $talkhf->talk_id = $hf_data['talk_id'];
        $talkhf->hfName = $hf_data['hfName'];
        $talkhf->hfNameId = $hf_data['hfNameId'];
        $talkhf->hfRole = $hf_data['hfRole'];
        $talkhf->hfTime = time();
        $talkhf->hfContent = $hf_data['hfContent'];
        $talkhf->atName = $hf_data['atName'];
        $talkhf->at_id = $hf_data['at_id'];
        $talkhf->at_role = $hf_data['at_role'];
        $talkhf->save();
        $talkhf_id = $talkhf->id;
        return $talkhf_id;
    }
    public function saveLikes($data)
    {
        $talk = new Talkhf;
        $num_org = db('talkhf')->where('id',$data['id'])->value('likes');
        $num = $num_org+$data['num'];
        $list = [
            'likes' => $num
        ];
        $result = $talk->save($list,['id' => $data['id']]);
        return $result;
    }
    
}